package com.kreateinfinity.msdi.web.authentication;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class LogoutController {
	private static Logger LOGGER = Logger.getLogger(LogoutController.class);
	
	
	@RequestMapping(value = "logout.html")
	public ModelAndView getLogout(Model model,HttpServletRequest request,HttpServletResponse response) throws Exception  {
			LOGGER.debug("is invoked");
			HttpSession session = request.getSession();
			response.setHeader("Cache-Control", "no-store"); // HTTP 1.1
			response.setHeader("Pragma", "no-cache"); // HTTP 1.0
			response.setDateHeader("Expires", -1); // prevents caching at the proxy
			response.setDateHeader("Max-Age", 0); // prevents caching at the proxy
			session.invalidate();
		 	ModelAndView modelAndView = new ModelAndView("redirect:login.html");
	        return modelAndView;
	}
	
}


